package ch3;

/**
 * Created by wyao on 17-3-6.
 * 使用条件操作符
 */
public class C3_5 {
    static int method1(boolean isdone) {
        if (isdone) {
            return 0;
        } else {
            return 1;
        }

    }

    static int method2(boolean isdone) {
        return (isdone ? 0 : 1);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000000000; i++) {
            C3_5.method1(true);
        }
        System.out.println(System.currentTimeMillis() - start);

        start = System.currentTimeMillis();
        for (int i = 0; i < 1000000000; i++) {
            C3_5.method2(true);
        }
        System.out.println(System.currentTimeMillis() - start);
    }
}
